package mysqlxa;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author sjw
 * @description
 * @date 2019-09-22 下午4:29
 */
public class TimeZoneUtil {


    public static void setTimeZone(String timeZoneStr){
        System.out.println(TimeZone.getDefault());
        SimpleDateFormat dfOld = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(dfOld.format(new Date()));

        final TimeZone timeZone = TimeZone.getTimeZone(timeZoneStr);
        //final TimeZone timeZone = TimeZone.getTimeZone("Asia/Shanghai");
        TimeZone.setDefault(timeZone);
        System.out.println(TimeZone.getDefault());
        SimpleDateFormat dfNew = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(dfNew.format(new Date()));
    }

    public static void main(String[] args) {
        setTimeZone("GMT+8:00");
    }





}
